<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        table tr th,td{
            border: 1px solid black;
            text-align: center;
        }
        table{
            border: 1px;
            cell-padding:0;
            cell-spacing:0;
            width: 80%;
            margin-top: 20px;
        }
        table thead{
            background-color:#b3d7ff ;
        }
        a{
            cursor: pointer;
        }

    </style>
    <link rel="stylesheet" href="../css/pintuer.css">
    <link rel="stylesheet" href="../css/bootstrap.css">

    <script src="../js/jquery-3.4.1.min.js"></script>
    <script src="../js/popper.min.js"></script>
    <script src="../js/bootstrap-table1.15.3.js"></script>
    <script src="../js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../js/bootstrap-min-4.3.1.js"></script>
    <script src="../js/pintuer.js"></script>
    <script src="../js/initMain.js"></script>
    <script type="text/javascript">
        function initTable(){
            $("#tableInfo").bootstrapTable({
                method:"post",
                contentType:"application/json",
                url:"/mApply/queryMApplyNoCheck.action",
                //设置交替行样式
                striped:true,
                //初始显示页数
                pageNum:1,
                //是否显示分页
                pagination:true,
                //设置是服务端分页还是客户端分页
                sidePagination:"server",
                //页大小
                pageSize:3,
                //分页列表
                pageList: [3,5,6,10],
                //上传到服务器的参数
                queryParams:function (data) {
                    return{
                        //计算页号，当前号
                        pageNum:(data.offset/data.limit)+1,
                        //计算页大小
                        pageSize: data.limit,
                    }
                },
                columns:[
                    {title:"生产计划编号",field:"applyId",align:"center"},
                    {title:"计划制定人",field:"designer",align:"center"},
                    {title:"登记人",field:"register",align:"center"},
                    {title:"登记时间",field:"registerTime",align:"center"},
                    {title:"备注",field:"remark",align:"center"},
                    {title:"审核",field:"id",align:"center",formatter:function (value,row,index) {
                            var btn="<a href='#' onclick='checkMApply("+JSON.stringify(row)+")'>审核</a>";
                            return btn;
                        }},
                ]

            })
        }

        $(function () {

            initTable();

        //点击提交按钮
        $(document).on("click","#checkMApply",function () {
            let mApply = new Object();
            mApply.applyId=mApplyObj.applyId;
            mApply.checker=$("#checker").text();
            mApply.checkTime=$("#checkTime").text();
            mApply.checkSuggestion=$("#checkSuggestion").val();
            mApply.checkTag=$("input[type='radio']:checked").val();
            $.ajax({
                data:"mApplyStr="+JSON.stringify(mApply),
                type:"post",
                url:"/mApply/checkMApply.action",
                success:function (data) {
                    $("#addModel").modal("hide");
                    $("#tableInfo").bootstrapTable("refresh");
                }
            })
        })


    })
        var mApplyObj;
        //点击审核按钮
        function checkMApply(obj) {
            // alert(obj.applyId);
            $.ajax({
                url:"/mApply/queryMApplyByApplyId",
                type:"post",
                data:"applyId="+obj.applyId,
                success:function (data) {
                    mApplyObj=obj;

                    $("#addModel").modal("show");
                    $("#tBody").empty();

                    $("#applyId").text(obj.applyId);
                    $("#register").text(obj.designer);
                    $("#registerTime").text(obj.registerTime);
                    $("#checker").text(localStorage.getItem("userName"));
                    var date=new Date();
                    $("#checkTime").text(date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+"  "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds());


                    for(var i=0;i<data.length;i++){
                        var mApply=data[i];
                        var trnew=$("<tr>");
                        var td=$("<td class='productId'>");
                        td.html(mApply.productId);
                        // count++;
                        var td1=$("<td>");
                        td1.text(mApply.productName);
                        var td2=$("<td>");
                        td2.text(mApply.amount);



                        trnew.append(td);
                        trnew.append(td1);
                        trnew.append(td2);

                        $("#tBody").append(trnew);


                    }

                }
            })
        }

    </script>
</head>
<body>
    <div>
        <table id="tableInfo">

        </table>
    </div>
    <div class="modal  fade" id="addModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width: 90%">
            <div class="modal-content" style="border: 1px solid black;">
                <div class="modal-header">
                    <div class="container">
                        <div class="row">
                            <div class="col-7" style="text-align: right">
                                <h5 class="modal-title" id="info" >
                                    生产计划单
                                </h5>
                            </div>
                            <div class="col-2"></div>
                            <div class="col-3" style="position: absolute;right: 30px">
                                <input type="radio" name="checkTag" value="S001-1" checked="checked">通过
                                <input type="radio" name="checkTag" value="S001-2">不通过
                                <button class="btn btn-primary" id="checkMApply" >提交</button>
                            </div>
                        </div>
                    </div>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-right: 0px">

                    </button>
                </div>
                <div class="modal-body">
                    <form id="addProcedureForm">
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-2" style="text-align: right">
                                    <span>计划单编号：</span>
                                </div>
                                <div class="col-4">
                                    <span id="applyId"></span><br>
                                </div>


                            </div>
                        </div><br>

                        <div class="container">
                            <div class="row">
                                <div class="col-2" style="text-align:right">
                                    登记人：
                                </div>
                                <div class="col-4">
                                    <span id="register"></span>
                                </div>
                                <div class="col-2" style="text-align:right">
                                    登记时间：
                                </div>
                                <div class="col-4">
                                    <span id="registerTime" ></span>
                                </div>
                            </div>
                        </div><br>


                        <table width="800px" style="margin-left: 20px">
                            <thead>
                                <tr>
                                    <th>产品编号</th>
                                    <th>产品名称</th>
                                    <th>数量</th>

                                </tr>
                            </thead>
                            <tbody id="tBody">

                            </tbody>
                        </table><br>

                        <div class="container">
                            <div class="row">
                                <div class="col-2" style="text-align:right">
                                    审核人：
                                </div>
                                <div class="col-4">
                                    <span name="checker" id="checker"></span>
                                </div>
                                <div class="col-2" style="text-align:right">
                                    审核时间：
                                </div>
                                <div class="col-4">
                                    <span  name="checkTime" id="checkTime"></span>
                                </div>
                            </div>
                        </div><br>
                        <span style="margin-left: 55px">审核意见：</span>
                        <textarea style="width: 550px;margin-left: 150px" class="form-control" id="checkSuggestion">

                        </textarea>

                    </form>
                </div>

            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>


</body>

</html>